package com.ktgj.other.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.other.domain.RcOrderInvoice;
import com.ktgj.other.service.IRcOrderInvoiceService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 专车订单发票Controller
 * 
 * @author ruoyi
 * @date 2022-07-27
 */
@RestController
@RequestMapping("/invoice")
public class RcOrderInvoiceController extends BaseController
{
    @Autowired
    private IRcOrderInvoiceService rcOrderInvoiceService;

    /**
     * 查询专车订单发票列表
     */
    @PreAuthorize(hasPermi = "other:invoice:list")
    @GetMapping("/list")
    public TableDataInfo list(RcOrderInvoice rcOrderInvoice)
    {
        startPage();
        List<RcOrderInvoice> list = rcOrderInvoiceService.selectRcOrderInvoiceList(rcOrderInvoice);
        return getDataTable(list);
    }

    /**
     * 导出专车订单发票列表
     */
    @PreAuthorize(hasPermi = "other:invoice:export")
    @Log(title = "专车订单发票", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RcOrderInvoice rcOrderInvoice) throws IOException
    {
        List<RcOrderInvoice> list = rcOrderInvoiceService.selectRcOrderInvoiceList(rcOrderInvoice);
        ExcelUtil<RcOrderInvoice> util = new ExcelUtil<RcOrderInvoice>(RcOrderInvoice.class);
        util.exportExcel(response, list, "专车订单发票数据");
    }

    /**
     * 获取专车订单发票详细信息
     */
    @PreAuthorize(hasPermi = "other:invoice:query")
    @GetMapping(value = "/{rcorderinvoiceid}")
    public AjaxResult getInfo(@PathVariable("rcorderinvoiceid") Long rcorderinvoiceid)
    {
        return AjaxResult.success(rcOrderInvoiceService.selectRcOrderInvoiceById(rcorderinvoiceid));
    }

    /**
     * 新增专车订单发票
     */
    @PreAuthorize(hasPermi = "other:invoice:add")
    @Log(title = "专车订单发票", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RcOrderInvoice rcOrderInvoice)
    {
        return toAjax(rcOrderInvoiceService.insertRcOrderInvoice(rcOrderInvoice));
    }

    /**
     * 修改专车订单发票
     */
    @PreAuthorize(hasPermi = "other:invoice:edit")
    @Log(title = "专车订单发票", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RcOrderInvoice rcOrderInvoice)
    {
        return toAjax(rcOrderInvoiceService.updateRcOrderInvoice(rcOrderInvoice));
    }

    /**
     * 删除专车订单发票
     */
    @PreAuthorize(hasPermi = "other:invoice:remove")
    @Log(title = "专车订单发票", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rcorderinvoiceids}")
    public AjaxResult remove(@PathVariable Long[] rcorderinvoiceids)
    {
        return toAjax(rcOrderInvoiceService.deleteRcOrderInvoiceByIds(rcorderinvoiceids));
    }
}
